import * as XLSX from 'xlsx'
export function getExcelData(file: any) {
  return new Promise(rel => {
    const reader = new FileReader()
    reader.readAsArrayBuffer(file)
    reader.onload = function () {
      const buffer: any = reader.result
      const bytes = new Uint8Array(buffer)
      const length = bytes.byteLength
      let binary = ''
      for (let i = 0; i < length; i++) {
        binary += String.fromCharCode(bytes[i])
      }
      const wb = XLSX.read(binary, {
        type: 'binary',
        cellDates: true
      })
      const outdata = XLSX.utils.sheet_to_json(wb.Sheets[wb.SheetNames[0]])
      rel(outdata)
    }
  })
}
